package com.syyo.gulimall.coupon.controller;

//import org.springframework.security.access.prepost.PreAuthorize;

import com.syyo.common.domain.ResultVo;
import com.syyo.common.utils.ResultUtils;
import com.syyo.gulimall.coupon.domain.req.HomeSubjectReq;
import com.syyo.gulimall.coupon.service.HomeSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 首页专题表【jd首页下面很多专题，每个专题链接新的页面，展示专题商品信息】
 *
 * @author syyo
 * @email syyo@gmail.com
 * @date 2021-01-20 09:35:54
 */
@RestController
@RequestMapping("/coupon/homesubject")
public class HomeSubjectController {

    @Autowired
    private HomeSubjectService homeSubjectService;

    /**
     * 新增
     */
    @PostMapping
    // @PreAuthorize("@syyo.check('system:homesubject:add')")
    public ResultVo add(@RequestBody HomeSubjectReq req) {
        return ResultUtils.ok(homeSubjectService.add(req));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{id}")
    // @PreAuthorize("@syyo.check('system:homesubject:del')")
    public ResultVo del(@PathVariable("id") Integer id) {
        return ResultUtils.ok(homeSubjectService.del(id));
    }

    /**
     * 修改
     */
    @PutMapping
    // @PreAuthorize("@syyo.check('system:homesubject:edit')")
    public ResultVo edit(@RequestBody HomeSubjectReq req) {
        return ResultUtils.ok(homeSubjectService.edit(req));
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public ResultVo findOne(@PathVariable("id") Integer id) {
        return ResultUtils.ok(homeSubjectService.findOne(id));
    }

    /**
     * 列表
     */
    @GetMapping("/list/{pageNum}/{pageSize}")
    public ResultVo findAll(@PathVariable("pageNum") Integer pageNum,
                            @PathVariable("pageSize") Integer pageSize,
                            HomeSubjectReq req) {
        return ResultUtils.ok(homeSubjectService.findAll(pageNum, pageSize, req));
    }

}
